package com.hong.aop.statisproxy;

import com.hong.aop.Greeting;
import com.hong.aop.GreetingImpl;

/**
 *  静态代理模式演示
 */
public class GreetingProxy implements Greeting {

    // 内部持有被代理接口的具体实现
    private GreetingImpl greetingImpl;

    public GreetingProxy(GreetingImpl greetingImpl) {
        this.greetingImpl = greetingImpl;
    }

    /**
     * 不符合开闭原则
     * @param name
     */
    @Override
    public void sayHello(String name) {
        before();
        greetingImpl.sayHello(name);
    }

    private void before(){
        System.out.println("before");
    }
}
